<style lang="less">
</style>
<template>
  <div>
    <h1>剩余积分：{{ currentRemainIntegral }} </h1>
    <h3>当前 人民币-积分 兑换率为 1:10</h3>
    <h3>可兑换人民币 {{ currentRemainIntegral/10 }} 元</h3>

    <Button @click="submitApply" style="margin: 10px 0px 0px 0px" type="primary">确认申请退款</Button>
  </div>
</template>
<script>
import { getUserList } from '@/api/users'
import { addApply } from '@/api/refundApply'

export default {
  components: {
  },
  data () {
    return {
      currentRemainIntegral: 0,
      username: ''
    }
  },
  created () {
    this.refreshIntegral()
  },
  methods: {
    submitApply () {
      let param = {
        userid: localStorage.userid, username: this.username, integral: this.currentRemainIntegral / 10
      }
      addApply(param).then(data => {
        this.$Message.success('申请已提交请等待管理员审批')
      })
    },
    refreshIntegral () {
      getUserList({id: localStorage.userid}).then(({data}) => {
        this.username = data.name
        this.currentRemainIntegral = data.integral === null ? 0 : data.integral
      })
    }
  }
}

</script>
<style>
</style>
